<?php
namespace App\Http\Requests;


use Illuminate\Validation\Rule;

class BjNotifyRequest extends BaseRequest {

    public function BjDoorStatusRules()
    {
        return [
            'type'       => ['required', Rule::in(['OPEN','CLOSE'])],
            'eventId'    => ['required', 'max:32', 'exists:swt_bj_open,event_id'],
            'eventType'  => ['required', Rule::in([1,4,5,6])],
            'outOpenNo'  => 'max:32',
            'cabinetNo'  => ['required', Rule::in([1,2])],
            'resultCode' => ['required', Rule::in(['SUCCESS', 'FAIL'])],
            'resultMsg'  => 'requiredIf:resultCode,FAIL'
        ];
    }

    public function BjVideoStatusRules()
    {
        return [
            'eventId'    => ['required', 'max:32', 'exists:swt_bj_open,event_id'],
            'outOpenNo'  => 'max:32',
            'deviceCode' => ['required', 'exists:swt_bj_machine,device_code'],
            'cabinetNo'  => ['required', Rule::in([1, 2])],
            'resultCode' => ['required', Rule::in(['SUCCESS', 'FAIL', 'UNOPENED'])],
            'resultMsg'  => 'requiredIf:resultCode,FAIL',
            'videoList'  => ['requiredIf:resultCode,SUCCESS','array'],
            'videoList.*.cameraNo' => ['requiredIf:resultCode,SUCCESS', Rule::in([1, 2])],
            'videoList.*.videoUrl' => ['requiredIf:resultCode,SUCCESS', 'url'],
        ];
    }

    public function BjMachineStatusRules()
    {
        return [
            'deviceCode'             => ['required', 'exists:swt_bj_machine,device_code'],
            'powerStatus'            => ['required', Rule::in([1, 2])],
            'netStatus'              => ['required', Rule::in([1, 2])],
            'saleStatus'             => ['required', Rule::in([1, 2])],
            'cabinetList'            => ['required', 'array'],
            'cabinetList.*.cabinetNo'  => ['required', Rule::in([1, 2])],
            'cabinetList.*.lockStatus' => ['required', Rule::in([1, 2])]
        ];
    }
}
